<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with music player - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=music+player</link>
      <pubDate>Sun, 08 Aug 2021 18:47:10 +0000</pubDate>
         <description>Tagged with music player - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedmusic+player/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>communicate between two macs in processing</title>
      <link>https://forum.processing.org/two/discussion/25841/communicate-between-two-macs-in-processing</link>
      <pubDate>Fri, 05 Jan 2018 20:53:36 +0000</pubDate>
      <dc:creator>Faffie</dc:creator>
      <guid isPermaLink="false">25841@/two/discussions</guid>
      <description><![CDATA[<p>Hello world,
I would like to know if it is possible to communicate between two macs in processing. What I mean:</p>

<p><em>Mac1 sends a signal to mac2 -&gt; mac2 plays an audio file -&gt; mac 2 waits for another signal sent by mac1 (loop)</em></p>

<p>In the code I have written I would love to send a signal to the second mac (mac2) at "int S5_MUSIC = 5;". So that there will be two sounds played at the same time. I need the second mac for a second pair of boxes, to create a surround sound....</p>

<p><strong>This is my processing code:</strong></p>

<pre><code>import processing.serial.*;
import processing.sound.*;


int S1_WAITING_FOR_PEOPLE  = 1;
int S2_PEOPLE_ENTERED      = 2;
int S3_LIGHT_FADE_OUT      = 3;
int S4_DARK                = 4;
int S5_MUSIC               = 5;
int S6_LIGHT_FADE_IN       = 6;
// make sure this is the last!!!!
int TERMINATE              = 7;

int mode = S1_WAITING_FOR_PEOPLE;




int no_one_when_distance_greater_then = 160; // cm
int time_before_dim = 5000; // ms

SoundFile file;
boolean is_playing = false;

Serial myPort;  

int dist;

boolean someone_present = false;
int someone_present_since_time;


int music_playing_since;
int music_duration;

int in_mode_since_ms;

void setup() {
  size(640, 360);

  printArray(Serial.list()); // "/dev/cu.usbmodem1411" cu.usb!!!

  myPort = new Serial(this, Serial.list()[1], 9600);
  //myPort.readStringUntil('\n');
  myPort.bufferUntil('\n');

  // Load a soundfile from the data folder of the sketch and play it back in a loop
  file = new SoundFile(this, "Ex.wav");
  //file.loop();
  music_duration = (int) file.duration() * 1000;
  music_duration += 2000;

}      

void draw() {
  background(0);
  fill(255);
  text("frameCount: "+frameCount, 50, 25);
  text("dist: "+dist, 50, 50);
  text("mode: "+mode, 50, 75);


  if (frameCount == 180) {
    turn_on();
  } else if (frameCount &gt; 180) {

    if ( mode == S1_WAITING_FOR_PEOPLE) {

      if (someone_present == false) {
        if (dist &lt; no_one_when_distance_greater_then) {
          someone_present = true;
          someone_present_since_time = millis();
          change_mode(mode + 1);
        }
      }
    } else if (mode == S2_PEOPLE_ENTERED) {
      text("millis: "+millis(), 50, 100);
      text("someone_present_since_time: "+someone_present_since_time, 50, 125);
      text("time_before_dim: "+time_before_dim, 50, 150);
      if (millis() - someone_present_since_time &gt; time_before_dim) {
        change_mode(mode + 1);
      }
    } else if (mode == S3_LIGHT_FADE_OUT) {
      turn_off();
      change_mode(mode + 1);
    } else if (mode == S4_DARK) 
    {
      change_mode(mode + 1);
    } else if (mode == S5_MUSIC) 
    {
      if (is_playing == false) {
        file.play();
        is_playing = true;
        music_playing_since = millis();
      }
      if (millis() - music_playing_since &gt; music_duration) {
        is_playing = false;
        file.stop();
        change_mode(mode + 1);
      }
    } else if (mode == S6_LIGHT_FADE_IN) 
    {
      // todo
      if (millis() - in_mode_since_ms &gt; 1000) {
        change_mode(mode + 1);
      }

    } else if (mode == TERMINATE) 
    {
      change_mode(S1_WAITING_FOR_PEOPLE);
      someone_present = false; // reset
      println("turn_on();");
      turn_on();
    }
  }
}


void change_mode(int m) {
  mode = m;
  in_mode_since_ms = millis();
}



void serialEvent(Serial p) { 
  String s = p.readString();
  if (s != null) {
    s = s.replace("\r\n", "");
    if (s.contains("Distance Measured")) {
      String[] tokens = split(s, "=");
      dist = int(tokens[1]);
    }
  }
} 


void turn_on() {
  myPort.write("on");
}

void turn_off() {
  myPort.write("off");
}

void keyPressed() {
  if (key == 'a') {
    turn_on();
  }
  if (key == 's') {
    turn_off();
  }
}
</code></pre>

<p>Thanks for your effort.
Faffie</p>
]]></description>
   </item>
   <item>
      <title>Creating A Virtual Launchpad with Webcam</title>
      <link>https://forum.processing.org/two/discussion/12517/creating-a-virtual-launchpad-with-webcam</link>
      <pubDate>Tue, 15 Sep 2015 09:16:22 +0000</pubDate>
      <dc:creator>Henaff</dc:creator>
      <guid isPermaLink="false">12517@/two/discussions</guid>
      <description><![CDATA[<p>Hi there !
I'm trying to create a launchpad with my webcam.
I've found few things about how to use my webcam to switch on/off a kind of "virtual button" to play an audio file.
And my problem is... I have no idea about how to assign each "virtual button" to an .mp3 file.</p>

<p>I think the problem is between lines 105 and 140... I'm HELPLESS !!</p>

<pre><code>import processing.video.*;
import ddf.minim.*;
import ddf.minim.ugens.*;
import ddf.minim.signals.*;
Capture cam;
Minim minim;
AudioPlayer player;


// Liste des samples //
AudioSample klaxon2;
AudioSample klaxon3;
AudioSample metro;
// Liste des samples //

AudioOutput out;
PImage img;

// Tracking vidéo //
import processing.video.*;
Capture video;
float txe = 0;
float tye = 0;
float alpha = 0.4;
int taille1 = 70 ;
int taille2 = 80 ;
int rouge = 10;


// Nombre de zones plus UNE !! //
zone_son[] lazone=new zone_son[3];
// Nombre de zones plus UNE !! //


float seuil=20;
boolean p=false;



void setup() { 

 size(displayWidth, displayHeight);
 cam = new Capture(this);
 cam.start(); 
 minim = new Minim(this);
 out = minim.getLineOut(Minim.STEREO);
 img = loadImage("Plan.jpg");



// Mes samples
klaxon2 = minim.loadSample("klaxon2.mp3");
klaxon3 = minim.loadSample("klaxon3.mp3");

lazone[0]=new zone_son(80, 0, 80, 80, "C3");
lazone[1]=new zone_son(1200, 0, 80, 80, "klaxon2.mp3");
lazone[2]=new zone_son(80, 600, 80, 80, "klaxon3.mp3");

} 

void draw() { 

 stroke(255);
 fill(255);
 text("Seuil : "+seuil,10,20);
 image(img, 0, 0);
 img.resize(width, height);


 if (cam.available()) { 
   // Reads the new frame
   cam.read();

   scale(-1,1); 
   translate(-width, 0);

   for (int i=0; i&lt; lazone.length;i++) {
     lazone[i].teste();
     lazone[i].dessine();
     lazone[i].joue();
   }
 }

} 





// modifier le seuil avec les touches haut et bas //
void keyPressed(){
 if(key==CODED){
   if(keyCode==UP){
     seuil+=1;
   }
   if(keyCode==DOWN){
     seuil-=1;
   }
   seuil=constrain(seuil,10,40);
 }


}

class zone_son {
 int px, py, lx, ly;
 String AudioSample;
 String note;
 boolean survol, joue;

 zone_son(int px, int py, int lx, int ly, String AudioSample) {
   this.px=px;
   this.py=py;
   this.lx=lx;
   this.ly=ly;
   this.AudioSample=AudioSample;
   this.note=AudioSample;
   survol=false;
   joue=false;
 }


 void joue(){
   if (survol==true &amp;&amp; joue==false){

klaxon2.trigger();


   joue=true;

 } 

  else if (survol==false &amp;&amp; joue==true){
     joue=false;
   }
 }



 void dessine() {

   stroke(255, 0, 50);

   if (survol==true){
     fill(255, 0, 50);
   } 
   else {
     fill(0, 0, 0);
   }

   ellipse(px,py,lx,ly);

 }


 void teste() {
   int presenceSum = 0;
   for (int x=px; x &lt; px+lx; x++) {
     for (int y=py;y &lt; py+ly;y++) {
       color currColor = cam.pixels[(y*width)+x];
       // Extract the red, green, and blue components of the current pixel’s color
       int cR = (currColor &gt;&gt; 16) &amp; 0xFF;
       int cG = (currColor &gt;&gt; 8) &amp; 0xFF;
       int cB = currColor &amp; 0xFF;
       presenceSum += cR + cG + cB;
     }
   }
   if (presenceSum/100000.0 &gt; seuil) {
     survol=true;
   } 
   else {
     survol=false;
   }
 }
}





void stop()
{
out.close();
minim.stop();
player.close();
klaxon2.close();
klaxon3.close();
super.stop();
}
</code></pre>

<p>IF you have any idea, you are welcome, THX.</p>
]]></description>
   </item>
   <item>
      <title>Flying Particles / Music Player (HD 720p)</title>
      <link>https://forum.processing.org/two/discussion/10780/flying-particles-music-player-hd-720p</link>
      <pubDate>Tue, 12 May 2015 19:22:22 +0000</pubDate>
      <dc:creator>atoro</dc:creator>
      <guid isPermaLink="false">10780@/two/discussions</guid>
      <description><![CDATA[<p>Made with Processing 
Flying Particles / Music Player (HD 720p) // gp 001 01 svsa
<span class="VideoWrap"><span class="Video YouTube" id="youtube-09j67sQ6WfQ"><span class="VideoPreview"><a href="http://youtube.com/watch?v=09j67sQ6WfQ"><img src="http://img.youtube.com/vi/09j67sQ6WfQ/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>
]]></description>
   </item>
   </channel>
</rss>